import * as PIXI from 'pixi.js'
import loadAssets from './loadAssets'
/** 常用按钮*/
export const btnsTexture = async (partName: string): Promise<PIXI.Texture> => {
  const assets = await loadAssets('btns')
  return assets.textures[partName]
}
export const btnsSprite = async (partName: string, width?: number, height?: number): Promise<PIXI.Sprite | PIXI.NineSliceSprite> => {
  const assets = await loadAssets('btns')
  const texture = assets.textures[partName]
  if (texture.defaultBorders === undefined) {
    return new PIXI.Sprite(texture)
  } else {
    const nineSliceSprite = new PIXI.NineSliceSprite(texture)
    width && (nineSliceSprite.width = width)
    height && (nineSliceSprite.height = height)
    return nineSliceSprite
  }
}
